﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Framework.Data.Core;
using System.Data;

namespace AppTestWPF.BusinessObjects
{
    public class Personne : BaseEntity
    {
        #region "Constructors"

        public Personne(IDbConnection connection = null)
            : base(connection)
        { }

        public Personne(bool setPrimeryKey, IDbConnection connection = null)
            : base(setPrimeryKey,connection)
        { }

        public Personne(IBaseEntity entity, bool duplicateChildren, IDbConnection connection = null)
            : base(entity, duplicateChildren, connection)
        { }

        #endregion

        #region "Properties"

        public long Id
        {
            get { return (long)this.GetField("ID_PERSON").Value; }
        }

        public string Name 
        {
            get { return this.GetField("NAME").Value.ToString(); }
            set { this.GetField("NAME").Value = value; }
        }

        #endregion

        #region "Methods"

        protected override void InitializeFields()
        {
            IEntityField field;
            field = new EntityField(this,typeof(long),"PERSON","ID_PERSON",-1,true,false,false);
            field.Schema = "BOIMER01";
            this.AddField("ID_PERSON",field);

            field = new EntityField(this,typeof(string),"PERSON","NAME",30,false,false,true);
            field.Schema = "BOIMER01";
            this.AddField("NAME",field);
        }
        
		protected override void SetPrimaryKey(IDbConnection connection)
		{
			throw new NotImplementedException();
		}

        #endregion
    }
}
